package com.itheima.springbootwebtlias.controller;

import com.itheima.springbootwebtlias.pojo.Result;
import com.itheima.springbootwebtlias.service.ReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@Slf4j
@RestController
@RequestMapping("/report")
public class ReportController {

    @Autowired
    private ReportService reportService;

    // 员工职位人数统计
    @GetMapping("/empJobData")
    public Result JobCount() {
        // 1.接受请求参数：无
        log.info("员工职位人数统计");
        // 2.调用业务层Service的功能方法，查询职位统计数据
        Map jobOption = reportService.jobCount();

        // 3.封装返回结果
        return Result.success(jobOption);
    }

    // 员工性别统计
    @GetMapping("/empGenderData")
    public Result genderCount() {
        // 1.接受请求参数：无
        log.info("员工性别统计");

        // 2.调用业务层Service的功能方法，查询性别统计数据
        List<Map> map = reportService.genderCount();

        // 3.封装返回结果
        return Result.success(map);
    }

    /**
     * 统计各个班级的学生人数
     */
    @GetMapping("/studentCountData")
    public Result getEmpClassData(){
        log.info("统计各个班级的学生人数");
        Map clazzOption = reportService.getClazzCountData();
        return Result.success(clazzOption);
    }

    /**
     * 学员学历统计
     */
    @GetMapping("/studentDegreeData")
    public Result getStudentDegreeData(){
        log.info("统计学员学历信息");
        List<Map> degreeList = reportService.getStudenDegreeData();
        return Result.success(degreeList);
    }
}
